﻿using System.IO;
using System.Reflection;
namespace WPFExcelReport.Helpers
{
    public static partial class Helper
    {
        public static  string ApplicationPath
        {
            get { return System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); }
        }

       public static string GetFullQualifedFileName(string fileName)
        {
            if (fileName.Contains(".\\"))
                return System.IO.Path.Combine(ApplicationPath, fileName.Remove(0, 2));
            else
                return fileName;
        }
        public static string CheckDirectory(string root, string sub)
        {

            string drlocal = root;

            if (!Directory.Exists(root))
                Directory.CreateDirectory(root);
            if (!Directory.Exists(root))
                return root;
            
            drlocal = root;
            if (!drlocal.EndsWith("\\"))
            {
                drlocal += "\\";
            }
            drlocal = Path.Combine(drlocal, sub);
            if (!Directory.Exists(drlocal))
                Directory.CreateDirectory(drlocal);
            return drlocal;
        }
    }
}
